home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / t-adainc / s-taruty.adb < prev    next >
Text File  |  1994-05-19  |  3KB  |  70 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --          S Y S T E M . T A S K I N G . R U N T Y P E _ T Y P E S         --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.4 $                            --
  10. --                                                                          --
  11. --           Copyright (c) 1991,1992,1993, FSU, All Rights Reserved         --
  12. --                                                                          --
  13. --  GNARL is free software; you can redistribute it and/or modify it  under --
  14. --  terms  of  the  GNU  Library General Public License as published by the --
  15. --  Free Software Foundation; either version 2,  or (at  your  option)  any --
  16. --  later  version.   GNARL is distributed in the hope that it will be use- --
  17. --  ful, but but WITHOUT ANY WARRANTY; without even the implied warranty of --
  18. --  MERCHANTABILITY  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Gen- --
  19. --  eral Library Public License for more details.  You should have received --
  20. --  a  copy of the GNU Library General Public License along with GNARL; see --
  21. --  file COPYING. If not, write to the Free Software Foundation,  675  Mass --
  22. --  Ave, Cambridge, MA 02139, USA.                                          --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. with System.Task_Primitives;  use System.Task_Primitives;
  27.  
  28. package body System.Tasking.Runtime_Types is
  29.  
  30.    ------------------------------------
  31.    -- Vulnerable_Complete_Activation --
  32.    ------------------------------------
  33.  
  34.    --  WARNING : Only call this procedure with priority already boosted.
  35.    --  That's why the name has "Vulnerable" in it.
  36.  
  37.    procedure Vulnerable_Complete_Activation
  38.      (T : ATCB_Ptr)
  39.    is
  40.       This_Task : ATCB_Ptr := ID_To_ATCB (Self);
  41.       Activator : ATCB_Ptr;
  42.  
  43.    begin
  44.       Activator := T.Activator;
  45.  
  46.       --  Decrement the count of tasks to be activated by the activator and
  47.       --  wake it up so it can check to see if all tasks have been activated.
  48.       --  Note that the locks of the activator and created task are locked
  49.       --  here.  This is necessary because C.Stage and
  50.       --  T.Activation_Count have to be synchronized.  This is also
  51.       --  done in Activate_Tasks and Init_Abortion.  So long as the
  52.       --  activator lock is always locked first, this cannot lead to deadlock.
  53.  
  54.       Write_Lock (Activator.L);
  55.       Write_Lock (T.L);
  56.  
  57.       if T.Stage = Can_Activate then
  58.          T.Stage := Active;
  59.          Activator.Activation_Count := Activator.Activation_Count - 1;
  60.       end if;
  61.  
  62.       Unlock (T.L);
  63.  
  64.       Cond_Signal (Activator.Cond);
  65.       Unlock (Activator.L);
  66.  
  67.    end Vulnerable_Complete_Activation;
  68.  
  69. end System.Tasking.Runtime_Types;
  70.